$(function () {
   var first = document.getElementsByTagName('input');
   var span = document.querySelectorAll('.dd')
   var sum = 60;
   var reg_mobile = /^1[3|4|5|7|8][0-9]{9}$/;
   var three = /^\d{4}$/;
   first[0].onblur = function () {
       if (reg_mobile.test(this.value)) {
           // console.log(1);
       }
       else if (this.value == this.value.length) {
           // console.log(2);
       }
       else {
           this.style.color='red'
           this.value = '请正确输入电话号码'
       }
   }
   first[0].onfocus = function () {
       this.style.color = 'black'
   }
   first[2].onblur = function () {
       if (three.test(this.value)) {
           console.log(1);
       }
       else if (this.value == this.value.length) {
           // console.log(2);
       }
       else {
           this.value = '验证码错误'
       }
   }
   
//提交
   $(".q_b").click(function(){
    // console.log(111);
    // console.log($(".tel").val());
    var pon= $(".q_1").val()
    var cod= $(".q_2").val()
    var user= $(".q_4").val()
    var pass= $(".q_5").val()
    $.ajax({
       url:"http://127.0.0.1:3000/users/register",
       data:{
          phone:pon,
          code:cod,
          username:user,
          password:pass
       },
       type:"post",
       success:function(res){
          console.log(res);
          
       }
    })
    
  })

   document.getElementById('qwe').onclick = function fu() {
       var a = 60;
       var time = function dao() {
           a--;
           document.getElementById('qwe').innerText = a 
           qwe.disabled = true;
           if (a == 0) {
               clearInterval(ting);
               qwe.disabled = false;
               document.getElementById('qwe').innerText = '重新获取'
           }
       }
       var ting = setInterval(time, 1000);
   }
})